<?php

use Phinx\Migration\AbstractMigration;

class CreateTenantStepLevelTable extends AbstractMigration
{

    public function up()
    {
        $table = $this->table('tenant_step_category_level', ['id' => false, 'primary_key' => ['id'], 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '租户工序级别表']);

        //添加数据字段
        $table->addColumn('id', 'integer', ['identity' => true, 'signed' => false, 'limit' => 11, 'comment' => '租户工序分类级别ID'])
            ->addColumn('tenant_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '租户ID'])
            ->addColumn('step_category_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '所属工序分类ID'])
            ->addColumn('step_category_name', 'string', ['default' => "", 'limit' => 128, 'comment' => '所属工序分类名称'])
            ->addColumn('step_category_code', 'string', ['default' => "", 'limit' => 128, 'comment' => '所属工序分类CODE'])
            ->addColumn('level', 'char', ['default' => '', 'limit' => 20, 'comment' => '认证级别'])
            ->addColumn('created', 'integer', ['signed' => false, 'null' => false, 'default' => 0, 'limit' => 11, 'comment' => '创建时间'])
            ->addColumn('created_by', 'integer', ['signed' => false, 'null' => false, 'default' => 0, 'limit' => 11, 'comment' => '创建人'])
            ->addColumn('updated', 'integer', ['signed' => false, 'null' => false, 'default' => 0, 'limit' => 11, 'comment' => '更新时间'])
            ->addColumn('uuid', 'char', ['default' => '', 'limit' => 36, 'comment' => '全局唯一标识符']);;

        //执行创建
        $table->create();
    }

    public function down()
    {
        $this->table("tenant_step_category_level")->drop();
    }
}
